﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/Core.Master" AutoEventWireup="true"
    CodeBehind="NewLoanList.aspx.cs" Inherits="Pap.Web.Modules.Loan.Views.NewLoanList"
    meta:resourcekey="PageResource1" %>

<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <script type="text/javascript">
        function ConfirmDeletion() {
            Ext.Msg.confirm('<asp:Literal runat="server" Text="<%$ Resources:MBConfirm %>" />', '<asp:Literal runat="server" Text="<%$ Resources:MBSureDelete %>" />', DeleteConfirmed);
        }

        function btnDeleteSelected_Clicked() {
            if (Ext.getCmp('grvLoans').hasSelection()) {
                ConfirmDeletion();
            }
        }

        function DeleteConfirmed(btn) {
            if (btn == "yes")
                Pap.DeleteSelectedLoans();
        }
    </script>

    <ext:Store runat="server" ID="storeLoans" OnRefreshData="Paging_Refresh" IDMode="Legacy"
        meta:resourcekey="storeLoansResource1">
        <Reader>
            <ext:JsonReader ReaderID="LoanID">
                <Fields>
                    <ext:RecordField Name="LoanID" />
                    <ext:RecordField Name="LoanNumber" />
                    <ext:RecordField Name="CustomerName" ServerMapping="CustomerObj.CustomerName" />
                    <ext:RecordField Name="LoanName" />
                    <ext:RecordField Name="LoanCreatedDate" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout runat="server" IDMode="Legacy" meta:resourcekey="FitLayoutResource1">
        <ext:GridPanel runat="server" ID="grvLoans" TrackMouseOver="true" StoreID="storeLoans"
            StripeRows="true" AutoExpandColumn="LoanName" meta:resourcekey="grvLoansResource1"
            SelectionMemory="Disabled" IDMode="Static">
            <ColumnModel>
                <Columns>
                    <ext:Column DataIndex="LoanNumber" Header="<%$Resources:loanNumberHeaderTitle %>">
                        <Commands>
                            <ext:ImageCommand Icon="Magnifier" CommandName="ViewLoan">
                                <ToolTip Text="<%$Resources:ViewReportTip %>" />
                            </ext:ImageCommand>
                        </Commands>
                    </ext:Column>
                    <ext:Column DataIndex="CustomerName" Header="<%$Resources:CustomerNameHeaderTitle %>" />
                    <ext:Column DataIndex="LoanName" Header="<%$Resources:loanNameHeaderTitle %>" />
                    <ext:Column DataIndex="LoanCreatedDate" Header="<%$Resources:LoanCreatedDateTitle %>">
                        <Renderer Fn="Ext.util.Format.dateRenderer('d/m/Y')" />
                    </ext:Column>
                    <ext:Column DataIndex="Notes" Header="<% $Resources:Notes %>">
                        <Editor>
                            <ext:TextArea runat="server" />
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <AjaxEvents>
                <Command OnEvent="GrvLoans_Command">
                    <ExtraParams>
                        <ext:Parameter Name="CommandName" Value="command" Mode="Raw" Encode="False" />
                        <ext:Parameter Name="LoanID" Value="record.data.LoanID" Mode="Raw" Encode="False" />
                    </ExtraParams>
                </Command>
            </AjaxEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Value="true" Mode="Raw" Encode="False" />
            </SelectionModel>
            <TopBar>
                <ext:Toolbar runat="server"> 
                    <Items>
                              <ext:Button runat="server" Icon="Accept" ID="btnSubmit" meta:resourcekey="btnSubmitResource1">
                    <AjaxEvents>
                        <Click OnEvent="Btn_Submit">
                            <ExtraParams>
                                <ext:Parameter Name="grvLoans" Value="Ext.encode(#{grvLoans}.getRowsValues(false))"
                                    Mode="Raw" />
                            </ExtraParams>
                            <EventMask ShowMask="true" />
                        </Click>
                    </AjaxEvents>
                </ext:Button>
                         <ext:Button runat="server" Text="<%$Resources:BtnDelete %>" Icon="Decline">
                            <Listeners>
                                <Click Handler="btnDeleteSelected_Clicked();" />
                            </Listeners>
                        </ext:Button>
                          
                    </Items>
                </ext:Toolbar>
                </TopBar>
                <BottomBar>
                <ext:StatusBar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Back" Icon="ArrowUndo">
                            <AjaxEvents>
                                <Click OnEvent="btnBack_Click"></Click>
                            </AjaxEvents>
                        </ext:Button>
                    </Items>
                </ext:StatusBar>
            </BottomBar>
            </ext:GridPanel>
    </ext:FitLayout>
</asp:Content>
